<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>类别管理</title>
    <jsp:include page="../../template/head.jsp"/>
    <link rel="stylesheet" href="/static/assets/plugins/zTree/css/zTreeStyle/zTreeStyle.css"/>
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">

    <header class="main-header">
        <!-- Logo -->
        <a href="index2.html" class="logo">

            <span class="logo-lg">My Shop</span>
        </a>
        <!-- Header Navbar: style can be found in header.less -->
        <nav class="navbar navbar-static-top">
            <!-- Sidebar toggle button-->


        </nav>
    </header>
    <!-- Left side column. contains the logo and sidebar -->
    <jsp:include page="../../template/menu.jsp"/>
    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <h1>
                类别管理

            </h1>

        </section>

        <!-- Main content -->
        <section class="content">
            <!-- Small boxes (Stat box) -->
            <div class="row">
                <div class="col-xs-12">
                    <div class="box box-info">
                        <div class="box-header with-border">
                            <h3 class="box-title"></h3>
                        </div>

                        <!-- /.box-header -->
                        <!-- form start -->
                        <form:form id="inputForm" cssClass="form-horizontal" modelAttribute="tbCategory">
                            <form:hidden path="id"/>
                            <div class="box-body">
                                <c:if test="${not empty result}">
                                    <div class="alert alert-danger alert-dismissible">
                                       ${result.msg}
                                    </div>
                                </c:if>
                                <div class="form-group">
                                    <label for="name" class="col-sm-2 control-label ">类别名称</label>
                                    <div class="col-sm-10">
                                        <form:input path="name" cssClass="form-control required"/>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label for="parentId" class="col-sm-2 control-label">父级类别</label>
                                    <div class="col-sm-10">
                                       <form:hidden path="parentId" cssClass="form-control required "/>
                                        <form:input  id="parent_text" path="father.name" readonly="true" cssClass="form-control required" onclick="App.myModal.showTree();"></form:input>

                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="sortOrder" class="col-sm-2 control-label">排序</label>
                                    <div class="col-sm-10">
                                        <form:input path="sortOrder" cssClass="form-control required"/>
                                    </div>
                                </div>

                            </div>
                            <!-- /.box-body -->
                            <div class="box-footer">
                                <a class="btn btn-default pull-left" onclick="history.go(-1)"><i class="fa fa-long-arrow-left"></i> 返回</a>
                                <button type="submit" class="btn btn-primary pull-right submit"><i class="fa fa-save"></i> 保存</button>
                            </div>
                            <!-- /.box-footer -->
                        </form:form>
                    </div>
                    <!-- /.box -->
                </div>
            </div>

        </section>
        <!-- /.content -->
    </div>
    <!-- /.content-wrapper -->
    <jsp:include page="../../template/copyright.jsp"/>
    <!-- /.control-sidebar -->
    <!-- Add the sidebar's background. This div must be placed
         immediately after the control sidebar -->

</div>
<!-- ./wrapper -->

<jsp:include page="../../template/foot.jsp"/>
<script src="/static/assets/plugins/zTree/jquery.ztree.core.min.js"></script>
<SCRIPT type="text/javascript">
    <!--
    var setting = {
        async: {
            enable: true,
            url:"/category/tree/data",



        },
        key:{
            isParent:"parent"
        },
        data: {
            simpleData: {
                enable: true,
                idKey: "id",
                pIdKey: "parentId",
                rootPId: 0
            }
        }
    };

    $(document).ready(function(){
        App.myModal.init(function (node) {
            $("#parent_text").val(node.name);
            $("#parentId").val(node.id);
        });
        $.fn.zTree.init($("#tree"), setting);
    });
    //-->
</SCRIPT>
</body>
</html>
